/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package serverv2_0;

/**
 *
 * @author suhui
 */
import java.io.*;
import java.net.*;
class TCPClient {
    public static void main(String argv[]) throws Exception
    {
        String sentence=null;
        String modifiedSentence;
        BufferedReader inFromUser = new BufferedReader(
                new InputStreamReader(System.in));
        Socket clientSocket = new Socket("localhost", 5000);
        ServerSocket receive = new ServerSocket(4000);
        
        DataOutputStream outToServer = new DataOutputStream(
                clientSocket.getOutputStream());
        
        //sentence = "type:command;action:send_client_list;";
        //sentence = "type:data;param:2;username:suhui;exp_gained:2001;";
        //sentence = "type:command;action:register;param:2;user:killers;password:123;";
       //sentence = "type:command;action:register;param:2;user:bored;password:123;";
        //sentence = "type:command;\naction:register;\nparam:2\nuser:gomez;\npassword:123;";
        //sentence = "type:command;action:login;param:2;user:gomez;password:1234;";
        outToServer.writeBytes(sentence+'\n' );
        Socket receives = receive.accept();
        BufferedReader inFromServer =
                new BufferedReader(new InputStreamReader(receives.getInputStream()                    ));
        
        while(!(modifiedSentence = inFromServer.readLine()).equals(""))
            System.out.println(modifiedSentence);
        
        
        clientSocket.close();
    }
}
